/*****日常渗透*****/
<template><!---->
  <search-table
	    ref="searchTable"
		  :columns="topoTargetCol"
      :data="topoTargetData"
      :total="topoTargetTotal"
      :page.sync="queryTopoTargetInfo.pageIndex"
      :size.sync="queryTopoTargetInfo.pageSize"
      @change-size="getTargetSize"
      @change-page="getTargetPage"
	>
  <Alert type="warning" show-icon v-if="configMode !== 1" slot="alert">
    <p style="color:#f90">注意事项:</p>
<!--    <p>	1.导入目标之前，请先去“拓扑页 > 展示编辑 > 3D编辑 > 地理区域划分”中，进行“行政区”处理</p>-->
    <p>	1.导入成功后，请前往"报告持续提交"页面，修改包含“目标方管理员组”的任务</p>
  </Alert>
  <template slot="search">
      <Upload ref="upload"
              class="mr15"
               v-if="configMode !== 1"
            :action="mixinUploadAction"
            :show-upload-list="false"
            :on-format-error="mixinHandleFormatError"
            :on-success="getImageUrl"
            :format="mixinFormat"
            :before-upload="mixinBeforeUpload"
            :headers="mixinUploadHeader" style="display:inline-block;">
            <!-- :max-size="mixinMaxSize"  :on-exceeded-size="mixinFileHasExceed"-->
      <Button type='primary' ghost icon="ios-cloud-upload-outline" :disabled="disabledAllBtn">
        导入目标
        <WarningTip content="请上传xlsx格式文件" style="vertical-align: text-bottom;"></WarningTip>
      </Button>
      </Upload>
      <Button type='primary' ref="downloadTemplateBtn" ghost v-if="configMode !== 1" icon="ios-cloud-download-outline" :disabled="disabledAllBtn"
        @click="downloadTemplate" class="mr15">
        <!--#57a3f3-->
        <a :href="mixinTemplateUrl" download='' style="color:#a5a5c6" @click.stop>模板下载</a>
      </Button>
<!--      <Button type='primary' ghost icon="ios-nuclear-outline" @click="issuedRules" :loading="issuedLoading"-->
<!--            v-if="(!allowChangeIp || deployMode === 2) && configMode !== 1 && hwExtentionType !== 2" :disabled="disabledAllBtn" class="mr15">下发规则</Button>-->
      <Button  type='primary' ghost  icon="ios-cloud-download-outline" @click="exportAdminExcel"
                :disabled="disabledAllBtn" class="mr15">
        <a :href="exportAdminUrl" style="color:#a5a5c6">导出管理员列表</a>
      </Button>
<!--      <Button type='primary' ghost icon="ios-nuclear-outline" @click="checkTopoTargetPosNum"-->
<!--              :disabled="disabledAllBtn" class="mr15">校验区域目标位置数量</Button>-->
<!--      <Button type='primary' ghost @click="assignTopoTargetPos"-->
<!--              :disabled="disabledAllBtn" class="mr15"><img src="../../../../assets/scene/target-allot-purple.png" alt=""/>分配目标位置 </Button>-->
      <Input v-model.trim="queryTopoTargetInfo.district" placeholder="区域" style="width:150px" class="mr15" @on-change="getTargetPage(1)"></Input>
      <Input v-model.trim="queryTopoTargetInfo.company" placeholder="单位" style="width:150px" class="mr15" @on-change="getTargetPage(1)"></Input>
      <Input v-model.trim="queryTopoTargetInfo.url" placeholder="Url" style="width:150px" @on-change="getTargetPage(1)"></Input>
      <Select filterable v-model="queryTopoTargetInfo.industry" placeholder="请选择行业" filterable clearable style="width:150px" @on-change="getTargetPage(1)">
        <Option :value="item.dictid" v-for="item in industryList" :key="item.dictid" :title="item.dictname">{{item.dictname}}</Option>
      </Select>
      <Select filterable transfer v-model="queryTopoTargetInfo.publicTarget" placeholder="是否公共目标" filterable clearable
          style="width:150px"  @on-change="getTargetPage(1)">
          <Option value="1">是</Option>
          <Option value="0">否</Option>
      </Select>
  </template>
  <Modal v-model="targetModal.show"
        :title="targetModal.title"
        :loading = "targetModal.loading"
        width="600px"
        :mask-closable = "false"
        @on-cancel="handleReset('formValidate')"
        @on-ok="saveTopoTarget">
        <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
          <FormItem  label="Url地址" prop="url">
            <Input v-model.trim="formValidate.url" placeholder="url"></Input>
          </FormItem>
          <!--<FormItem  label="是否可用" prop="available">
            <RadioGroup v-model="formValidate.available">
              <Radio :label=1>可用</Radio>
              <Radio :label=0>不可用</Radio>
            </RadioGroup>
          </FormItem>-->
          <FormItem  label="单位" prop="company">
            <Input v-model.trim="formValidate.company" placeholder="单位" :disabled="targetModal.type == 2"></Input>
          </FormItem>
          <FormItem  label="区域" prop="district">
            <Input v-model.trim="formValidate.district" placeholder="区域" disabled v-if="targetModal.type == 2"></Input>
            <Select filterable v-model="formValidate.district" placeholder="请选择区域" filterable :disabled="targetModal.type == 2" v-if="targetModal.type == 1">
              <Option :value="district" v-for="district in districtList" :key="district" :title="district">{{district}}</Option>
            </Select>
          </FormItem>
          <FormItem  label="行业" prop="industry">
            <Select filterable v-model="formValidate.industry" placeholder="请选择行业" filterable>
              <Option :value="item.dictid" v-for="item in industryList" :key="item.dictid" :title="item.dictname">{{item.dictname}}</Option>
            </Select>
          </FormItem>
          <FormItem  label="Ip" prop="ip">
            <Input v-model.trim="formValidate.ip" placeholder="多个ip请用，隔开,例如：192.168.1.12,192.168.1.13,192.168.1.14"></Input>
          </FormItem>
          <FormItem  label="是否公共目标" prop="publicTarget">
            <Select filterable v-model="formValidate.publicTarget" placeholder="请选择是否公共目标" filterable>
              <Option value="1">是</Option>
              <Option value="0">否</Option>
            </Select>
          </FormItem>
        </Form>
      </Modal>
    <Modal
      v-model="checkModal"
      title="校验结果"
      width="600px"
        :mask-closable = "false"
        footer-hide>
      <Table border :columns="checkCol" :data="checkList"></Table>
    </Modal>
  </search-table>
</template>

<script>
  import {getTopoTargetList,addTopoTarget,modifyTopoTarget_old,delTopoTarget,importTarget,queryNetworkList,getDistricts,exportAdminExcel,assignTopoTargetPos,checkTopoTargetPosNum, queryVmWithParty, getExecutionsResult} from '@/api/drill_compete'
  import {getFlagServerList,getstatusbyprjid, issuedRules } from '@/api/drill'
  import {getaccessgrouplist} from '@/api/access_new'
  import { allDirection } from  '@/api/dict'
  import hwTargetMangeMixin from '@/mixin/hwTargetMangeMixin'

  export default {
    name: 'scenes',
    props:['type', 'disabledAllBtn', 'allowChangeIp', 'deployMode','configMode','hwExtentionType'],
    components:{},
    mixins: [hwTargetMangeMixin],
  data(){
    const validateNum = (rule, value, callback) => { //验证只能填入数字
      var reg = new RegExp("^([1-9]|[1-9]\\d|100)$");
      //验证警戒值
      if(value){
        if (!reg.test(value)) {
          callback(new Error('请输入1-100的整数'));
        }else{
          callback()
        }
      }else{
        callback()
      }
    }
    const validateIPs = (rule, value, callback) => { //验证只能填入数字
      var reg = new RegExp("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
      //验证警戒值
      if(value){
        let ipArr = value.split(',');
        if(ipArr.some((ip) => !reg.test(ip))){
          callback(new Error('ip格式错误'));
        }else{
          callback()
        }
      }else{
        callback()
      }
    }
    return {
      issuedLoading: false,
      routeParams:{
        id:this.$route.query.id,
        prjid:this.$route.query.prjid
      },
      targetModal:{
        show:false,
        title:'',
        loading:true,
        type:1 //1添加，2修改
      },
      pathList:[],
      accessGroupList:[],
      vmlists:[],
      teamlists:[],
      queryTopoTargetInfo:{
        pageIndex:1,
        pageSize:10,
        projectId:this.$route.query.prjid
      },
      access:'1',
      formValidate: {
        "company": "",
        "district": "", //区域
        "id": "",
        "industry": "",
        "url":"",
        "projectId": this.$route.query.prjid,
        "available":true,
        "ip":"",
        "publicTarget": ''
      },
      ruleValidate: {
        ip:[
          { validator: validateIPs, trigger: 'change' }
        ],
        url: [
          { required: true,message: '不能为空', trigger: 'change' },
        ],
        company: [
          { required: true,message: '不能为空', trigger: 'change' },
        ],
        industry: [
          { required: true,message: '不能为空', trigger: 'change' },
        ]
      },
      querytime:{},
      topoTargetCol:[
        {
          title:'单位',
          key:'company',
          align:'center',
          ellipsis:true,
          tooltip:true,
          placement:'top-left',
          width: 200
        },
        {
          title:'Url地址',
          key:'url',
          align:'center',
          ellipsis:true,
          tooltip:true,
          width:300
        },
        {
          title:'题目名称',
            key:'questionName',
            align:'center',
            ellipsis:true,
            tooltip:true,
            width: 160,
            show:this.type == 1
        },
        {
          title:'IP',
          key:'ip',
          align:'center',
            width: 110
        },
        {
          title:'行业',
          key:'industryName',
          align:'center',
          width: 110,
          tooltip:true
        },
        {
          title:'是否公共目标',
          key:'publicTarget',
          align:'center',
          tooltip:true,
          render:(h,params) => {
            return h('span', params.row.publicTarget ?  '是' : '否' )
          }
        },
        {
          title:'区域',
          key:'district',
          align:'center',
          placement:'top-left'
        },
        // {
        //   title:'绑定状态',
        //   key:'score',
        //   align:'center',
        //   placement:'top-right',
        //   ellipsis:true,
        //   tooltip:true,
        //   render:(h,params) => {
        //     return h('Tag',{
        //       props:{
        //         color:(params.row.x && params.row.y) ? 'success' :'default',
        //         type:"border"
        //       },
        //       on:{
        //         click:()=>{
        //         }
        //       }
        //     },(params.row.x && params.row.y) ?  '已绑定' : '未绑定' )
        //   }
        // },
        {
          title:'操作',
          key:'action',
          ellipsis:true,
          width:200,
          placement:'top-right',
          key:'action',
          show:(data) => {
              return this.configMode !== 1
          },
          opList:[
              {
                  txt:'修改',
                  type:'modify',
                  disabled: () => {
                    return this.disabledAllBtn
                  },
                  fun:this.showAddAndUpdate,
                  show:(data) => {
                      return this.configMode !== 1
                  }
              },
              {
                  txt:'删除',
                  type:'delete',
                  tooltip:true,
                  disabled: () => {
                    return this.disabledAllBtn
                  },
                  fun:(data) => {
                      this.delTopoTarget(data.id)
                  },
                  title: '你确定要删除吗?',
                  show:(data) => {
                      return this.configMode !== 1
                  }
              }
          ],
          // render:(h,params)=>{
          //   return h('div',[
          //     h('Button',{
          //       props:{
          //         type:'text',
          //         size:'small',
          //         disabled:this.disabledAllBtn
          //       },
          //       style:{
          //         border:'none',
          //         background:'none',
          //         boxShadow:'none',
          //         display: this.configMode === 1 ? 'none':'inline-block'
          //       },
          //       on:{
          //         click:()=>{
          //           this.showAddAndUpdate(params.row)
          //         }
          //       }
          //     },[
          //       h('img', {
          //           attrs: {
          //             src:this.disabledAllBtn ? require('../../../../assets/project/modifys.png') : require('../../../../assets/project/modifys-h.png')
          //           },
          //           style: {
          //             cursor: 'pointer',
          //             'vertical-align': 'middle',
          //             display:'inline-block',
          //             marginBottom:'4px',
          //           },
          //       }),
          //     ]),
          //     h('Poptip', {
          //       props: {
          //         confirm: true,
          //         'ok-text': "确定",
          //         'cancel-text': "取消",
          //         type: 'error',
          //         size: 'large',
          //         title: '你确定要删除吗?',
          //         transfer:true
          //       },
          //       on: {
          //         'on-ok': () => {
          //           this.delTopoTarget(params.row.id)
          //         }
          //       }
          //     }, [
          //       h('Button', {
          //         props: {
          //           type: 'text',
          //           size: 'small',
          //           disabled:this.disabledAllBtn
          //         },
          //         style: {
          //           border:'none',
          //           background:'none',
          //           boxShadow:'none',
          //           display: this.configMode === 1 ? 'none':'inline-block'
          //         },
          //       }, [
          //         h('img', {
          //             attrs: {
          //               src:this.disabledAllBtn ? require('../../../../assets/project/delNote-d.png') : require('../../../../assets/project/delNote-h.png')
          //             },
          //             style: {
          //               cursor: 'pointer',
          //               'vertical-align': 'middle',
          //               display:'inline-block',
          //               marginBottom:'4px',
          //             },
          //         }),
          //       ])
          //     ])
          //   ])
          // }
        }
      ],
      topoTargetData:[],
      topoTargetTotal:0,
      TargetId:'',
      projectInfo:{},
      subnetList:[],
      districtList:[],
      exportAdminUrl:'',
      //目标数量检测
      checkModal:false,
      checkList:[],
      checkCol:[
        {
          title:'验证结果',
          key:'msg',
        },
        {
          title:'导入的区域',
          key:'district',
        },
        {
          title:'导入的总量',
          key:'count',
        },
        {
          title:'拓扑图总量',
          key:'topoCount',
        },
        {
          title:'是否足够',
          key:'enough',
        }
      ],
      industryList: [],
      hwType: 3,
    }
  },
  filters:{

  },
  async mounted(){
    await this.getIndustryTypes()
    this.getProjectInfo();
    this.getDistricts();
    this.exportAdminUrl=`../../api/compete/old/targetAdmin/exportExcel?projectId=${this.$route.query.prjid}&testId=${this.$route.query.id}`
    this.getAccessGroupList();
    this.getTopoTargetList();
    // if(this.type == 1){
    //   this.topoTargetCol.splice(2, 0, {
    //     title:'题目名称',
    //       key:'questionName',
    //       align:'center',
    //       ellipsis:true,
    //       tooltip:true,
    //       width: 160,
    //       show:this.type == 1
    //   });
    // }
  },
  methods:{
    // 点击模板下载按钮，需要触发事件
    downloadTemplate() {
      this.$refs.downloadTemplateBtn.$el.querySelector('a').click()
    },
    // 获取行列列表
    getIndustryTypes() {
      return new Promise(resolve => {
        allDirection({ dictTypeID: 'hwIndustryTypes' }).then(({ code, message, attribute = {} }) => {
          attribute = attribute.attribute || []
          if (code !== 1) {
            this.$Message.warning(message)
            return
          }
          let list = []
          attribute.forEach(item => list = list.concat(item.dictEntryList))
          this.industryList = list
        }).catch(() => {
          this.$Message.error('获取行业列表异常')
        }).finally(() => {
          resolve()
        })
      })
    },
    // 下发团队规则或者竞赛系统路由规则
    issuedRules() {
      this.issuedLoading = true
      issuedRules(this.$route.query.id).then(async ({ code, message }) => {
        if (code !== 1) {
          this.cancelBtnLoading()
          this.$Message.warning(message)
        } else {
          this.$Message.info('下发规则成功')
          // self->TabPane->Tabs->hwDrillDetail，所以需要三个$parent
          this.$parent.$parent.$parent.changePreDefault('routerRules')
        }
      }).catch(() => {
          this.cancelBtnLoading()
          this.$Message.error(`下发规则异常`);
      })
    },
    cancelBtnLoading() {
      this.issuedLoading = false
    },
    getExecutionsResult(ids){
      return new Promise((resolve,reject) => {
        getExecutionsResult(ids).then(data => {
          if(data.code == 1){
            resolve(data);
          }else{
            this.$Message.warning(data.message);
            reject();
          }
        }).catch(error => {
          this.$Message.error('查询下发状态异常');
          reject();
        })
      })
    },
    awaitWrap(promise){
      return promise
        .then(data => [null, data])
        .catch(err => [err, null])
    },
    initData(){
      this.formValidate = {
        "company": "",
        "district": "", //区域
        "id": "",
        "industry": "",
        "url":"",
        "projectId": this.$route.query.prjid,
        "available":1,
        "publicTarget": ''
      }
    },
    showAddAndUpdate(info){
      this.initData();
      this.targetModal.show = true;
      if(!info){
        this.targetModal.title = '添加目标';
        this.targetModal.type = 1;
        this.access = "1";
      }else{
        this.targetModal.title = '修改目标';
        this.targetModal.type = 2;
        this.formValidate = JSON.parse(JSON.stringify(info));
        this.formValidate.publicTarget = info.publicTarget ? '1' : '0'
      }
    },
    addTopoTarget(){
      let params = JSON.parse(JSON.stringify(this.formValidate));
      params.publicTarget = params.publicTarget === '1'
      addTopoTarget(params).then(data => {
        if(data.code==1){
          this.getTopoTargetList();
          this.handleReset('formValidate');
          this.targetModal.show = false;
        }else{
          this.cancelLoading('targetModal');
          this.$Message.warning(data.message);
        }
      }).catch(error => {
        this.cancelLoading('targetModal');
        this.$Message.error(error.response.data.message || error);
      })
    },
    modifyTopoTarget(){
      let params = JSON.parse(JSON.stringify(this.formValidate));
      params.publicTarget = params.publicTarget === '1'
      params.testId = this.$route.query.id;
      modifyTopoTarget_old(params).then(data => {
        if(data.code==1){
          this.getTopoTargetList();
          this.$Message.info('操作成功');
          this.handleReset('formValidate');
          this.targetModal.show = false;
        }else{
          this.cancelLoading('targetModal');
          this.$Message.warning(data.message);
        }
      }).catch(error => {
        this.cancelLoading('targetModal');
        this.$Message.error(error.response.data.message || error);
      })
    },
    saveTopoTarget(){
      this.$refs['formValidate'].validate((valid) => {
        if (valid) {
          if(this.targetModal.type == 1){
            this.addTopoTarget();
          }else{
            this.modifyTopoTarget();
          }
        }else{
          this.cancelLoading('targetModal');
        }
      })
    },
    getTopoTargetList(){
      getTopoTargetList(this.queryTopoTargetInfo).then(data => {
        if(data.code==1){
          let list = data.data.items || data.data
          this.topoTargetData = list.map(item => {
            item.industryName = this.getIndustryName(item.industry)
            return item
          })
          this.topoTargetTotal = data.data.total;
        }else{
          this.$Message.warning(data.message);
        }
      })
    },
    // 将行业Id转换为对应的名称
    getIndustryName(industryId) {
      let item = this.industryList.find(item => item.dictid === industryId)
      // 返回对应的名称，没有查到数据，还是返回ID
      return item ? item.dictname : industryId
    },
    delTopoTarget(id){
      let projectId = this.$route.query.prjid;
      delTopoTarget(id,projectId).then(data => {
        if(data.code==1){
          // 删除后展示当前页，当前页没有数据展示前一页
          this.$Message.info('删除成功')
          this.queryTopoTargetInfo.pageIndex = (this.topoTargetData.length == 1 && this.queryTopoTargetInfo.pageIndex > 1) ?
              this.queryTopoTargetInfo.pageIndex - 1 : this.queryTopoTargetInfo.pageIndex;
          this.getTopoTargetList();
        }else{
          this.$Message.warning(data.message);
        }
      }).catch(() => {
        this.$Message.error('删除异常')
      })
    },
    cancelLoading(name){
      this[name].loading = false;
        setTimeout(() => {
          this[name].loading = true;
        })
    },
    typeFilter(val){
      let str = '';
      switch (val) {
        case 0:str = 'Flag';break;
        case 1:str = '多个虚拟机Flag相同';break;
        case 2:str = '多个虚拟机Flag不同';break;
        case 3:str = '文档';break
        default:break;
      }
      return str;
    },
    statusFilter(val){
      let str = '';
      switch (val) {
        case 1:str = '正常/防护成功';break;
        case 2:str = '被攻破';break;
        case 3:str = '服务异常';break;
        case 4:str = '被攻破+服务异常';break
        default:break;
      }
      return str;
    },
    getAllVmlist(partyId,imageId){
      let params = {
        page:1,
        pageSize:10000,
        sortBy:'name',
        order:'asc',
        findPorts:true
      }
      if(this.question){
      }
      if(this.group){
        params.party = this.group.partyId;
      }
      queryVmWithParty(this.routeParams.prjid,params).then(data => {
        if(data.code == 1){
          this.vmlists = data.data.list || data.data;
          if(this.vmlists.length > 0){
            let server = this.vmlists.filter(vm => vm.id == this.formValidate.vmId)[0];
            if(server){
              this.getFlagServerList(server.address[0].ips[0].ipAddress);
            }
          }
        }
      })
    },
    getAccessGroupList(){
      if(!this.routeParams.id){
        return;
      }
      let params = {
        pageIndex:1,
        pageSize:2147483647,
        testId:this.routeParams.id
      };
      this.selectGroupList = [];
      getaccessgrouplist(params).then(data => {
        if(data.code == 1){
          this.accessGroupList = data.data.items;
        }else if(data.code == -2) {
          this.accessGroupList = [];
        }else{
          this.$Message.warning(data.message);
        }
      })
    },
    getTargetSize(size){
      this.queryTopoTargetInfo.pageSize = size;
      this.getTopoTargetList()
    },
    getTargetPage(page){
      this.queryTopoTargetInfo.pageIndex = page;
      this.getTopoTargetList()
    },
    setTeamQuestion(val){
      if(!val){
        return
      }
      this.question = this.questionList.filter(question => question.chaId == val)[0];
      this.formValidate.port = this.question.port;
      this.getAllVmlist();
    },
    changeTeamGroup(val){
      this.formValidate.vmId = '';
      if(!val){
        return
      }
      this.setTeamGroup(val);
    },
    setTeamGroup(val){
      if(!val){
        return
      }
      this.group =  this.accessGroupList.filter(group => group.id == val)[0];
      this.formValidate.teamName = this.group.name;
      this.getAllVmlist();
    },
    handleReset (name) {
      this.initData();
      this.$refs [name].fields.forEach(function (e) {
        if (e.fieldValue != undefined && e.fieldValue!='') {
            e.resetField()
        }
      })
    },
    changeVm(id){
      this.formValidate.path = '';
      this.getVmIp(id);
    },
    getVmIp(id){
      if(id){
        let server = this.vmlists.filter(vm => vm.id == id)[0];
        this.getFlagServerList(server.address[0].ipv4);
      }
    },
    getFlagServerList(ip){
      let curIp = ip.split('.').slice(0,3).join('.');
      let params = {
        page:1,
        pageSize:1000,
        projectId:this.$route.query.prjid,
        ip:curIp
      }
      getFlagServerList(params).then(data => {
        if(data.code == 1){
          //this.pathList = data.data.list;
          this.formValidate.path = data.data.list[0].addresses[0].applyFlagUrl;
        }
      })
    },
    changeAccess(access){
    },
    showImportModal(){
    },
    importFromExcel(){
      importTarget(this.$route.query.id).then(data => {
        if(data.code == 1){

        }
      })
    },
    getImageUrl(res){
      if(res.code == 1){
        this.queryTopoTargetInfo.pageIndex = 1
        this.queryTopoTargetInfo.district = ''
        this.queryTopoTargetInfo.company = ''
        this.queryTopoTargetInfo.url = ''
        this.queryTopoTargetInfo.industry = ''
        this.$Message.info('导入成功，请前往"报告持续提交"页面，修改包含“目标方管理员组”的任务')
        this.getTopoTargetList();
      }else{
        this.$Message.warning(res.message);
      }
    },
    getProjectInfo(){
      getstatusbyprjid(this.$route.query.prjid).then(data => {
        if(data.code == 1){
          this.projectInfo = data.attribute;
        }
      })
    },
    getProjectSubnet(){
      queryNetworkList(this.$route.query.prjid,this.projectInfo.network.id).then(data => {
        if(data.code == 1){
          let subnetList = [];
          data.attribute.editorStage.childs.forEach(item => {
            subnetList = subnetList.concat(item.childs);
          })
          this.subnetList = [...new Set(subnetList.filter(subnet => subnet.district).map(subnet => subnet.district))];
        }
      })
    },
    getDistricts(){ //获取区域列表
      let params = {
        projectId:this.$route.query.prjid
      }
      getDistricts(params).then(data => {
        if(data.code == 1){
          this.districtList = data.data.list;
        }
      })
    },
    exportAdminExcel(){//导出管理员列表
      let params = {
        projectId:this.$route.query.prjid,
        testId:this.$route.query.id,
        companyId:''
      }
      exportAdminExcel(params).then(data => {
        if(data.code == 1){

      }else{
        this.$Message.warning(data.message);
      }
      })
    },
    //分配目标位置
    assignTopoTargetPos(){
      let projectId = this.$route.query.prjid;
      assignTopoTargetPos(projectId).then(data => {
        if(data.code == 1){
          this.$Message.info('分配成功');
        }else{
          this.$Message.error(data.message);
        }
      }).catch(error => {
        this.$Message.error('服务异常');
      })
    },
    //校验区域靶标位置数量
    checkTopoTargetPosNum(){
      let projectId = this.$route.query.prjid;
      checkTopoTargetPosNum(projectId).then(data => {
        if(data.code == 1){
          this.checkList = data.data;
          this.checkModal = true;
        }else{
          this.checkList = [];
          this.$Message.error(data.message);
        }
      }).catch(error => {
        this.$Message.error('服务异常');
      })
    },
  },
  beforeDestroy(){
    clearTimeout(this.timer)
  },
}
</script>
<style scoped>
.mr15 {
    margin-right: 15px;
}
</style>
<style>
.drillsTable .ivu-poptip-body {
  text-align: left!important;
}
.scenesHeader{
  margin-bottom: 16px;
}
.drillTables{
  min-height: 300px;
}
.drillsTable.ivu-table-wrapper{
  overflow: inherit;
}
.targetHeader{
  /*padding: 10px;*/
  margin:15px 0;
}
.targetHeader .flex {
    display: flex;
    justify-content: space-between;
}
.active-zone {
  margin-bottom: -8px;
  display: flex;
  flex-wrap: wrap;
}
.active-zone>div,
.active-zone>button {
  margin-right: 15px;
  margin-bottom: 8px;
}
</style>
